binaryEncode
Type
function
Summary
Encodes a set of values into a set of binary values.
Syntax
binaryEncode(<formatsList>, <dataStringList>)
Description
Use the binaryEncode function to encode one or more values as binary data.
The binary data format produced by binaryEncode is similar to the format produced by the "pack()" function of the Perl programming language.
If you don't specify a number with the a, A, b, B, h, or H dataTypes, one character is encoded. If the dataType normally takes more than one character, trailing zeroes are added to make up the required number of characters. For example, H requires two characters, so binaryEncode("H","3") Encodes the hexadecimal number 30, adding a zero to the end to make the dataString two characters long.
Parameters
Name | Type | Description |
---|---|---|
formatsList | The formatsList consists of one or more dataTypes, each followed optionally by an amount. A dataType is one of the following letters:
The amount is an integer or * and specifies the encoding in the following way:
| |
dataStringList | string | A comma-separated list of dataStrings. Each dataString is a string, or an expression that evaluates to a string. |
Examples
binaryEncode("a","Q") -- returns "Q"
binaryEncode("A5","QED") -- returns "QED "
binaryEncode("N2a12x",firstNum,secondNum,labelString,"nothing")
charToNum(binaryEncode("B*","01111111")) -- returns 127
Related
control structure: function
glossary: return, binary file, value, null, encode, binary data, hexadecimal
keyword: string, character, characters
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile